<?php

namespace App\Models\Admin;
use Illuminate\Database\Eloquent\Model;

class CollPlace extends Model{
    protected $table='coll_place';
    protected $primaryKey='id';
    public $timestamps = false;
    protected $guarded =[];

    /**
     * 获取地标信息
     * @return array
     * $pid:省份的id
     */
    public static function getPlace($pid){
        $place = self::where('pid', $pid)->get();
        $placeArray = array();
        if(!empty($place)){
            $place = setSort($place);
            foreach($place as $key => $value){
                $placeArray[] = array('name' => $value['name'], 'longitude' => $value['longitude'], 'latitude' => $value['latitude']);
            }
        }
        return $placeArray;
    }
    /**
     * 获取地标的中文
     * $cid:选项编号
     * @return： 选项名称
     */
    public static function getPlaceName($cid){
        $place = self::where('cid', $cid)->first();
        if($place){
            return $place->name;
        }
        return '';
    }
}
